package com.mondo.financialwallet.data.repository.datasource;

import com.mondo.financialwallet.data.entity.BasisResponseEntity;
import com.mondo.financialwallet.data.entity.HoldProductDetailsEntity;
import com.mondo.financialwallet.data.entity.HoldProductListEntity;
import com.mondo.financialwallet.data.entity.HoldProductProfitDataEntity;
import com.mondo.financialwallet.data.entity.LoginUserInfoEntity;
import com.mondo.financialwallet.data.entity.ProductListEntity;
import com.mondo.financialwallet.data.entity.ProductOrderListEntity;
import com.mondo.financialwallet.data.entity.UserAssetsEntity;
import com.mondo.financialwallet.data.entity.UserInfoEntity;
import com.mondo.financialwallet.data.net.DefaultWebService;

import java.io.File;

import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

public class RemoteDefaultDataStore implements DefaultDataStore {

    @Override
    public Observable<UserInfoEntity> userDetails() {
        return DefaultWebService.get().userDetails();
    }

    @Override
    public Observable<UserAssetsEntity> userAssets() {
        return DefaultWebService.get().userAssets();
    }

    @Override
    public Observable<BasisResponseEntity> modifyAvatar(File avatar) {
        return DefaultWebService.get().modifyAvatar(
                MultipartBody.Part.createFormData("head_image", avatar.getName(),
                        RequestBody.create(MediaType.parse("multipart/form-data"), avatar))
        );
    }

    @Override
    public Observable<BasisResponseEntity> register(
            String mobileNumber, String password, String code, String invitationCode) {
        return null;
    }

    @Override
    public Observable<LoginUserInfoEntity> login(String mobileNumber, String password) {
        return DefaultWebService.get().login("", mobileNumber, password);
    }

    @Override
    public Observable<BasisResponseEntity> alterNickname(String nickname) {
        return DefaultWebService.get().alterNickname(nickname);
    }

    @Override
    public Observable<BasisResponseEntity> resetLoginPassword(
            String password, String mobileNumber, String token, String code) {
        return null;
    }

    @Override
    public Observable<BasisResponseEntity> alterLoginPassword(
            String oldPassword, String newPassword, String code) {
        return DefaultWebService.get().alterLoginPassword(oldPassword, newPassword, code);
    }

    @Override
    public Observable<BasisResponseEntity> bindNewMobileNumber(
            String mobileNumber, String prefix, String code) {
        return DefaultWebService.get().bindNewMobileNumber(mobileNumber, prefix, code);
    }

    @Override
    public Observable<BasisResponseEntity> bindEmail(String email, String code) {
        return DefaultWebService.get().bindEmail(email, code);
    }

    @Override
    public Observable<ProductListEntity> productList() {
        return DefaultWebService.get().productList();
    }

    @Override
    public Observable<ProductOrderListEntity> productOrderList() {
        return DefaultWebService.get().productOrderList();
    }

    @Override
    public Observable<HoldProductListEntity> holdProductList() {
        return DefaultWebService.get().holdProductList();
    }

    @Override
    public Observable<HoldProductDetailsEntity> holdProductDetails(String orderNumber) {
        return DefaultWebService.get().holdProductDetails(orderNumber);
    }

    @Override
    public Observable<HoldProductProfitDataEntity> holdProductProfitData(String orderNumber) {
        return DefaultWebService.get().holdProductProfitData();
    }

    @Override
    public Observable<BasisResponseEntity> clearHoldProduct(String orderNumber, String code) {
        return DefaultWebService.get().clearProduct(orderNumber, code);
    }
}
